package com.mec.web.y2012.ebookshop;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

/**
 * Servlet implementation class ShopServlet
 */
@WebServlet("/ShopServlet")
public class ShopServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShopServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    

	@Override
	public void init(ServletConfig config) throws ServletException {
		logger.info("*** initializing controller servlet.");
		super.init(config);
		//
		DataManager dataManager = new DataManager();
		dataManager.setDbUrl(config.getInitParameter(DataManager.PARAM_DB_URL));
		dataManager.setDbUserName(config.getInitParameter(DataManager.PARAM_DB_USER_NAME));
		dataManager.setDbPassword(config.getInitParameter(DataManager.PARAM_DB_PASSWORD));
		
		//
		try{
			Class.forName(config.getInitParameter(DataManager.PARAM_JDBC_DRIVER_NAME));
		}catch(ClassNotFoundException e){
			logger.error("Load JDBC Driver failed.", e);
		}
	}



	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	
	private static final Logger logger =
			Logger.getLogger(ShopServlet.class);
}
